package com.zhuang.reggie.controller;

import com.zhuang.reggie.common.R;
import com.zhuang.reggie.entity.Orders;
import com.zhuang.reggie.mapper.OrderMapper;
import com.zhuang.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    
    @Autowired
    private OrderService orderService;

    /**
     * 用户下单
     * @param orders
     * @return
     * 请求 URL: http://localhost:8080/order/submit
     * 请求方法: POST
     * 参数：{"remark":"不要筷子","payMethod":1,"addressBookId":"1529647748209467393"}
     *
     * 提交的参数只有地址id有用途，需要我们自己查询当前登录用户的用户信息、购物车信息、以及当前地址id的地址信息
     */
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        log.info("订单数据：{}",orders);
        orderService.submit(orders);
        return R.success("下单成功");
    }
}
